package com.ruoyi.web.tdm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.tdm.domain.TdmPeiFangKeLi;
import com.ruoyi.web.tdm.service.ITdmPeiFangKeLiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 配方颗粒Controller
 * 
 * @author ly
 * @date 2022-03-11
 */
@RestController
@RequestMapping("/tdm/TdmPeiFangKeLi")
public class TdmPeiFangKeLiController extends BaseController
{
    @Autowired
    private ITdmPeiFangKeLiService tdmPeiFangKeLiService;

    /**
     * 查询配方颗粒列表
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmPeiFangKeLi:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmPeiFangKeLi tdmPeiFangKeLi)
    {
        startPage();
        List<TdmPeiFangKeLi> list = tdmPeiFangKeLiService.selectTdmPeiFangKeLiList(tdmPeiFangKeLi);
        return getDataTable(list);
    }

    /**
     * 导出配方颗粒列表
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmPeiFangKeLi:export')")
    @Log(title = "配方颗粒", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmPeiFangKeLi tdmPeiFangKeLi)
    {
        List<TdmPeiFangKeLi> list = tdmPeiFangKeLiService.selectTdmPeiFangKeLiList(tdmPeiFangKeLi);
        ExcelUtil<TdmPeiFangKeLi> util = new ExcelUtil<TdmPeiFangKeLi>(TdmPeiFangKeLi.class);
        util.exportExcel(response, list, "配方颗粒数据");
    }

    /**
     * 获取配方颗粒详细信息
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmPeiFangKeLi:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmPeiFangKeLiService.selectTdmPeiFangKeLiById(id));
    }

    /**
     * 新增配方颗粒
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmPeiFangKeLi:add')")
    @Log(title = "配方颗粒", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmPeiFangKeLi tdmPeiFangKeLi)
    {
        return toAjax(tdmPeiFangKeLiService.insertTdmPeiFangKeLi(tdmPeiFangKeLi));
    }

    /**
     * 修改配方颗粒
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmPeiFangKeLi:edit')")
    @Log(title = "配方颗粒", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmPeiFangKeLi tdmPeiFangKeLi)
    {
        return toAjax(tdmPeiFangKeLiService.updateTdmPeiFangKeLi(tdmPeiFangKeLi));
    }

    /**
     * 删除配方颗粒
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmPeiFangKeLi:remove')")
    @Log(title = "配方颗粒", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmPeiFangKeLiService.deleteTdmPeiFangKeLiByIds(ids));
    }
}
